package pers.qianyu.month_202102.date_20210228;

/**
 * 896. 单调数列
 * https://leetcode-cn.com/problems/monotonic-array/
 *
 * @author mizzle rain
 * @date 2021-02-28 12:49
 */
public class IsMonotonic {
    public boolean isMonotonic(int[] A) {
        int n = A.length;
        if (n == 0 || n == 1) return true;
        boolean a = true, b = true;
        for (int i = 1; i < n; i++) {
            if (A[i] - A[i - 1] > 0) a = false;
            if (A[i] - A[i - 1] < 0) b = false;
        }
        return a | b;
    }
}
